


void setup() {
  pinMode(9,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(10,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(A0,OUTPUT);
  pinMode(A1,OUTPUT);
  pinMode(A2,OUTPUT);
  pinMode(A3,OUTPUT);
  pinMode(A4,OUTPUT);
  pinMode(A5,OUTPUT);//设置为输出
  analogWrite(9,0);
  analogWrite(10,0);
  analogWrite(6,0);
  analogWrite(5,0);
  digitalWrite(A0,LOW);
  digitalWrite(A1,LOW);
  digitalWrite(A2,LOW);
  digitalWrite(A3,LOW);
  digitalWrite(A4,LOW);
  digitalWrite(A5,LOW);
  digitalWrite(2,LOW);
  digitalWrite(4,LOW);
}

void go()//前进
{
  analogWrite(9,150);//PWM速度设置为150
  analogWrite(10,150);
  analogWrite(6,150);
  analogWrite(5,150);
  digitalWrite(A0,HIGH);//设置A0为高
  digitalWrite(A1,LOW);//设置A1为低
  digitalWrite(A2,HIGH);
  digitalWrite(A3,LOW);
  digitalWrite(A4,HIGH);
  digitalWrite(A5,LOW);
  digitalWrite(2,HIGH);
  digitalWrite(4,LOW);
}
void left_turn()//左转
{
  analogWrite(9,150);//PWM速度设置为150  占空比为151/256
  analogWrite(10,150);
  analogWrite(6,150);
  analogWrite(5,150);
  digitalWrite(A0,HIGH);
  digitalWrite(A1,LOW);
  digitalWrite(A2,HIGH);
  digitalWrite(A3,LOW);
  digitalWrite(A5,HIGH);
  digitalWrite(A4,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(2,LOW);
}
void back()//后退
{
  analogWrite(9,150);
  analogWrite(10,150);
  analogWrite(6,150);
  analogWrite(5,150);
  digitalWrite(A0,LOW);
  digitalWrite(A1,HIGH);
  digitalWrite(A2,HIGH);
  digitalWrite(A3,LOW);
  digitalWrite(A4,HIGH);
  digitalWrite(A5,LOW);
  digitalWrite(2,HIGH);
  digitalWrite(4,LOW);
}
void right_turn()//右转
{
  analogWrite(9,150);
  analogWrite(10,150);
  analogWrite(6,150);
  analogWrite(5,150);
  digitalWrite(A0,HIGH);
  digitalWrite(A1,LOW);
  digitalWrite(A2,HIGH);
  digitalWrite(A3,LOW);
  digitalWrite(A5,HIGH);
  digitalWrite(A4,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(2,LOW);
}
void left()//左平移
{
  analogWrite(9,150);
  analogWrite(10,150);
  analogWrite(6,150);
  analogWrite(5,150);
  digitalWrite(A0,HIGH);
  digitalWrite(A1,LOW);
  digitalWrite(A2,HIGH);
  digitalWrite(A3,LOW);
  digitalWrite(A4,HIGH);
  digitalWrite(A5,LOW);
  digitalWrite(2,HIGH);
  digitalWrite(4,LOW);
}
void right()//右平移
{
  analogWrite(9,150);
  analogWrite(10,150);
  analogWrite(6,150);
  analogWrite(5,150);
  digitalWrite(A0,HIGH);
  digitalWrite(A1,LOW);
  digitalWrite(A2,HIGH);
  digitalWrite(A3,LOW);
  digitalWrite(A5,HIGH);
  digitalWrite(A4,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(2,LOW);
}

void loop()
{
  go();
}






